#ifndef _I_ASSET_H_
#define _I_ASSET_H_

#include "../cuCommon/cuTypes.h"

#include "../interface/I_Buffer.h"

#include "../interface/I_SpatialTree.h"

#include "../rtCommon/Box.h"

enum e_Asset_Data_Flag
{
	e_Asset_Data_Pos = 1,
	e_Asset_Data_Nml = 2,
	e_Asset_Data_Tnt = 4,
	e_Asset_Data_Bnt = 8,
	e_Asset_Data_Clr = 16,
	e_Asset_Data_UV = 32,
	e_Asset_Data_Idx = 64,
	e_Asset_Data_Tree = 128,
};

class I_Asset
{
public:
	I_Buffer			* m_pPos;
	I_Buffer			* m_pNml;
	I_Buffer			* m_pTnt;
	I_Buffer			* m_pBnt;
	I_Buffer			* m_pClr;
	I_Buffer			* m_pUV;

	I_Buffer			* m_pPosIdx;

	I_SpatialTree * m_pTree;

	S_Box						m_Box;

	matrix4x4				m_Model;

public:
	I_Asset()
	{
		Null();

		Matrix4x4SetIdentity(m_Model);
	}

	virtual ~I_Asset() { Release(); }

	virtual void Null()
	{
		m_pPos = NULL;
		m_pNml = NULL;
		m_pTnt = NULL;
		m_pBnt = NULL;
		m_pClr = NULL;
		m_pUV = NULL;

		m_pPosIdx = NULL;

		m_Box.pmax = f3();
		m_Box.pmin = f3();

		m_pTree = NULL;
	}

	virtual void Release()
	{
		delete m_pPos; 
		delete m_pNml; 
		delete m_pTnt; 
		delete m_pBnt;
		delete m_pClr; 
		delete m_pUV;

		delete m_pTree;

		delete m_pPosIdx;

		Null();
	}

	virtual void						Create(int nVertexCount, int nFaceCount, int nFlag, I_api_Device * pDevice=NULL)=0;
	virtual void						Create(int nVertexCount, int nFaceCount, int nFlag, I_Asset * pShared)=0;

	virtual bool						Deserialize(char * pFileName, I_api_Device * pDevice=NULL)=0;
	virtual bool						Deserialize(char * pFileName, I_Asset * pShared)=0;

	virtual void						Build(int nType)=0;

	virtual bool						Serialize(char * pFileName)=0;

	virtual int							nPrimitive()=0;
	virtual int							nVertex()=0;

	virtual I_SpatialTree	*	Tree() { return m_pTree; }

	virtual S_Box						Box() { return m_Box; }
};

#endif